# 计算矩形面积
def juxingmianji(length,width):
    return length * width
result = juxingmianji(4,3)
print(result)

# 打印借阅书籍情况
def borrow_books(name,book,day):
    print(f"{name}借阅了书籍《{book}》,预计借阅{day}天")
borrow_books("小千","红楼梦",14)
borrow_books("小锋","西游记",10)

#求一个三位数个、十、百位的值
def cal_digit(number):
    high = number // 100
    mid = number // 10 % 10
    low = number % 10
    return high, mid, low
result = cal_digit(543)
print(result)
a,b,c = cal_digit(543)
print(a,b,c)

#判断单年份是不是闰年
def is_leap(year):
    """
    判单年份是不是闰年
    :param year:年份
    :return:返回值为布尔类型
    """
    if (year%4 == 0 and year%100 != 0) or year%400 == 0:
        return True
    else:
        return False
print(is_leap.__doc__)

#
def favorite_place(name,place):
    print(f"我的名字是{name}")
    print(f"我最喜欢的名胜古迹是{place}")
favorite_place("小千","万里长城")

#
def favorite_place(name,place):
    print(f"我的名字是{name}")
    print(f"我最喜欢的名胜古迹是{place}")
favorite_place(place="桂林山水",name="小锋")

#
def personinfo(*languages,**info):
    for key,value in info.items():
        print(f"{key}:{value}")
    print("喜欢的编程语言如下：")
    for language in languages:
        print(language,end=" ")
personinfo("C","C++","Python",id=1,name="小千",age=19,grade="大二")


#
def product(a,b,c):
    return a * b * c
tuple01 = (22,10,22)
print(product(*tuple01))
list01 = [22,10,22]
print(product(*list01))

#
def product(a,b,c):
    return a * b * c
dict01 = {
    "a":22,
    "b":10,
    "c":22
}
print(product(**dict01))

#
def join_str(brand_str):
    brand_str = "www." + brand_str + ".com"
    return brand_str
brand = "codingke"
url = join_str(brand)
print("品牌名称为：",brand)
print("网址为：",url)

#
def change_shelves(goods_list):
    goods_list.append("礼盒")
    return goods_list
alist = ["牛奶","薯片","巧克力"]
result = change_shelves(alist)
print(alist)
print(result)

#
class Student:
    def __init__(self,name,id):
        self.name = name
        self.id = id
        self.age = 19
    def update_age(self,age):
        """用于修改属性age的值"""
        self.age = age
s1 = Student("小千",202201)           #创建实例对象
print(f"{s1.name}的年龄是{s1.age}")
s1.update_age(20)                          #调用修改年龄的方法
print(f"{s1.name}的年龄修改为{s1.age}")

#
class Room:
    def __init__(self,name):
        self.__name = name        #定义私有属性__name
    def print_name(self):         #定义方法访问私有属性
        print(f"房间的名称为{self.__name}")
r1 = Room("房间1")                 #创建一个实例对象
r1.print_name()

